module.exports = (sequelize, Sequelize) => {
    return sequelize.define("pure_operation_logs", {
        id: { 
            type: Sequelize.INTEGER, 
            autoIncrement: true, 
            primaryKey: true 
        },
        user_id: { 
            type: Sequelize.INTEGER, 
            allowNull: true, 
            comment: '操作用户ID' 
        },
        api_path: { 
            type: Sequelize.STRING, 
            allowNull: false, 
            comment: '接口路径'
        },
        method: { 
            type: Sequelize.STRING, 
            allowNull: false, 
            comment: '请求方法'
        },
        request_headers: { 
            type: Sequelize.JSON, 
            allowNull: true, 
            comment: '请求头信息'
        },
        request_body: { 
            type: Sequelize.JSON, 
            allowNull: true, 
            comment: '请求体'
        },
        response_headers: { 
            type: Sequelize.JSON, 
            allowNull: true, 
            comment: '响应头信息'
        },
        response_body: { 
            type: Sequelize.JSON, 
            allowNull: true, 
            comment: '响应体'
        },
        ip_address: { 
            type: Sequelize.STRING, 
            allowNull: true, 
            comment: 'IP 地址'
        },
        location: { 
            type: Sequelize.STRING, 
            allowNull: true, 
            comment: '操作地点'
        },
        os: { 
            type: Sequelize.STRING, 
            allowNull: true, 
            comment: '操作系统'
        },
        browser: { 
            type: Sequelize.STRING, 
            allowNull: true, 
            comment: '浏览器类型'
        },
        duration: { 
            type: Sequelize.INTEGER, 
            allowNull: true, 
            comment: '请求耗时（毫秒）'
        },
        request_time: { 
            type: Sequelize.DATE, 
            allowNull: true, 
            comment: '请求时间'
        },
        status: {
            type: Sequelize.BOOLEAN,
            defaultValue: 1,
            comment: '状态 0:失败 1:成功',
        },
    },{
        updatedAt: false,
        comment: '操作日志表',
    });
};
